<?php
/**
 * @ClassName: CommonEnum
 * @Description: 公共枚举
 * @author: wyaohu
 * @Date: 2024/9/8 20:04
 * @Version: V1.0.0
 */

namespace app\common\enum;

class CommonEnum
{
    const del_yes = 1;
    const del_no = 0;

    const check_stay = 0;//待审核
    const check_success = 1;//审核通过
    const check_fail = 2;//审核驳回
    const check_apply = 4;//申请中

    const trade_type_add = 1;
    const trade_type_sub = 0;

    const merchant_type_xw = 1;
    const merchant_type_gt = 2;
    const merchant_type_qy = 3;

    /**
     * 删除状态 0否 1是
     * @param $status
     * @return string|string[]
     */
    public static function delText($status)
    {
        $desc = [
            CommonEnum::del_yes => '是',
            CommonEnum::del_no => '否',
        ];
        if ($status === true) {
            return $desc;
        }
        return $desc[$status] ?? $status;
    }

    /**
     * 审核状态 0待审核 1审核通过 2审核驳回
     * @param $status
     * @return string|string[]
     */
    public static function examineText($status)
    {
        $desc = [
            CommonEnum::check_stay => '待审核',
            CommonEnum::check_success => '已通过',
            CommonEnum::check_fail => '已驳回',
            CommonEnum::check_apply => '申请中',
        ];
        if ($status === true) {
            return $desc;
        }
        return $desc[$status] ?? $status;
    }

    /**
     * 星期
     * @param $level
     * @return string|string[]
     */
    public static function weeks($level)
    {
        $desc = [
            1 => '周一',
            2 => '周二',
            3 => '周三',
            4 => '周四',
            5 => '周五',
            6 => '周六',
            7 => '周日',
        ];
        if ($level === true) {
            return $desc;
        }
        return $desc[$level] ?? $level;
    }

    /**
     * 交易类型
     * @param $level
     * @return string|string[]
     */
    public static function tradeTypes($level)
    {
        $desc = [
            CommonEnum::trade_type_add => '增加',
            CommonEnum::trade_type_sub => '减少',
        ];
        if ($level === true) {
            return $desc;
        }
        return $desc[$level] ?? $level;
    }

    /**
     * 商户类型
     * @param $level
     * @return string|string[]
     */
    public static function merchantTypes($level)
    {
        $desc = [
            CommonEnum::merchant_type_xw => '小微',
            CommonEnum::merchant_type_gt => '个体',
            CommonEnum::merchant_type_qy => '企业',
        ];
        if ($level === true) {
            return $desc;
        }
        return $desc[$level] ?? $level;
    }

}